package com.xbongbong.saas.enums;

import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.pro.constant.OptionalRangeFieldConstant;
import lombok.Getter;

import java.util.Objects;

/**
 * @author sunshaoxiang
 * @date 2021/09/03 10:55
 */
@Getter
public enum OptionalRangeFieldEnum {
    USER_NAME(FieldTypeEnum.USER_NAME, OptionalRangeFieldConstant.USER_NAME ),
    DEPT_NAME(FieldTypeEnum.DEPT_NAME, OptionalRangeFieldConstant.DEPT_NAME),
    ROLE_NAME(FieldTypeEnum.ROLE_NAME, OptionalRangeFieldConstant.ROLE_NAME),
    ;

    private FieldTypeEnum fieldTypeEnum;

    private String[] loginList;

    OptionalRangeFieldEnum(FieldTypeEnum fieldTypeEnum, String[] loginList) {
        this.fieldTypeEnum = fieldTypeEnum;
        this.loginList = loginList;
    }

    public static OptionalRangeFieldEnum getByCode(Integer fieldType) {
        for (OptionalRangeFieldEnum optionalRangeFieldEnum: values()) {
            if (Objects.equals(optionalRangeFieldEnum.getFieldTypeEnum().getType(), fieldType)) {
                return optionalRangeFieldEnum;
            }
        }
        return null;
    }

}
